﻿/// <reference path="../typings/tsd.d.ts" />
/// <reference path="../scripts/autojs/auto.d.ts" />

$(function () {
    /*DOM
        <input id="fu" type="file" value="" />
        <input id="fu2" type="file" value="" />
    */
    /*JS的用法 */
    $("#fu").autoFileUploader({ url: "/api/SYS/fileupload" });
    $("#fu2").autoFileUploader({ url: "/api/SYS/fileupload2", filter: '.jpg|.txt|.docx', text: '请选择文件' })
        .on("done", function (event,msg) {
            console.log("响应了done事件" + msg);
        })
        .on("canceled", function (event) {
            console.log("响应了cancle事件");
        })
        .on("error", function (event,msg) {
            console.log("响应了error事件" + msg);
        });
    enum Color { Red, Green, Blue }
    console.log(Color.Red);


    $.auto.setupWS("localhost", 20000);
    $.auto.ajax("/api/tmp/org", {
        data: { dwdm: 1 }
    }).done(function (data) {
        $("#posdiv").screenfull();
    }) 

   /* $.ajax("/api/tmp/org", {
        type:'POST',dataType:'json'
    }).done(function (ret) {
        
    });*/
    /*1、添加面板 */
    //$("#layout").tabpanel();
    //$("#layout").tabpanel("add", { id: "a", title: "shena", url: "/home/index" });
    //$("#layout").tabpanel("add", { id: "b", title: "shenb", url: "/home/index" });
    //$("#layout").tabpanel("add", { id: "c", title: "shenc", url: "/home/index" });
    //$("#layout").tabpanel("add", { id: "d", title: "shend", url: "/home/index" });
    //$("#layout").tabpanel("add", { id: "e1", title: "shene", url: "/home/index" });

    /*2\ 表格应用*/
  let data = [];
    for (let i = 1; i <= 100; i++)
        data.push({
            name: "shen" + i,
            age: i,
            address: "address is " + i

        });


    $("#tt").autoTable({
        data: data,
        header: [
            [{ title: "序号", span: [] },
                { title: "姓名", span: [] },
                { title: "年龄|age", span: [] },
                { title: "住址", span: [] }]
        ],
        headerFields: ["name", "age", "address"],
        isRownumber: true,
        isFooter: true,
        isPageable: true,
        columnsWidths: [50, 80, 60, 120],
        sortFields: ["age"],
        selectMode: AUTO.SelectMode.MULTI,
        keydataOnRow: ["age"],

        editUrl: "aa",
        editTable: "tjxx_01",
        editKeyFields: ["name"],
        editFields: ["age", "address"],
        editTopHover: true,
        filter: function (row) {
            return row.age % 3 != 0;
        }
    });

     

    /*  $("form").autoForm({
        ajaxurl: 'aaa',
        cols: 2,
        fields: [
            { field: "XMID", type: "prikey" },
            { field: "XMMC", title: "项目名称", type: "string", span: 1 },
            { field: "QKMC", title: "合同区块名称", type: "string", span: 1 },
            { field: "YQTMC", title: "油气田名称", type: "string", span: 1 },
            { field: "XMZT", title: "项目状态", type: "string", span: 1 },
            { field: "YZ", title: "业主", type: "string", span: 1 },
            { field: "CBS", title: "承包商", type: "string", span: 1 },
            { field: "JSGM", title: "建设规模", type: "string", span: 1 },
            { field: "JHZTZE", title: "计划总投资额", type: "number", placeholder: "万元", span: 1 },
            { field: "SJZTZE", title: "实际总投资额", type: "number", placeholder: "万元", span: 1 },
            { field: "JHKGRQ", title: "计划开工日期", type: "date", span: 1 },
            { field: "JHGQ", title: "计划工期", type: "number", placeholder: "天", span: 1 },
            { field: "SJKGRQ", title: "实际开工日期", type: "date", span: 1 },
            { field: "SJGQ", title: "实际工期", type: "number", placeholder: "天", span: 1 }],
        tableName: "ap_ttt",


    });




    $("#ny").autoDate("ny");


    $.auto.setupWS("localhost", 20000);
    var shen = "shenjunjian";
    $("#join").click(function () {
        $.auto.join("fgs", function (data) {
            console.log(this);
            console.log(data);
            console.log(shen);
        });
    });
    $("#leave").click(function () {
        $.auto.leave("fgs");
    });
    $("#broadcast").click(function () {
        $.auto.broadcast("fgs", "aaa");
    });

    /*  $("button").click(function () {
        var t1 = new Date();
        $.auto.ajax("/api/tmp/org", {
            data: { dwdm: 1 }
        }).done(function (data) {
            console.log("socket:" + (new Date().valueOf() - t1.valueOf()));
        }) 
        setTimeout(function () {
            var t2 = new Date();
            $.ajax("/api/tmp/org", {
                data: { dwdm: 1 }, type: 'POST', dataType: 'json'
            }).done(function (data) {
                console.log("ajax:" + (new Date().valueOf() - t2.valueOf()));
            })
        }, 2000);
    });*/
});
